<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" layout:decorate="main"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .x_content form ul {
            list-style: none;
        }

        .x_content form ul li {
            width: 350px;
            display: inline-block;
            height:40px;
            line-height: 40px;
            vertical-align: middle;
        }
    </style>
</head>
<body>
    <div layout:fragment="content">
        <div class="clearfix"></div>
        <div class="row">
            <div class="col-md-12">
                <div class="x_panel">
                    <div class="x_title">
                        <h2>
                            服务分配 <i class="fa fa-user"></i>
                            <small>
                                - 您可以通过搜索或者其他的筛选项对服务分配的信息进行编辑、删除等管理操作。^_^
                            </small>
                        </h2>
                        <div class="clearfix"></div>
                    </div>
                    <div class="x_content">
                        <form method="post" action="/service/dispatch">
                            <input type="hidden" name="pageIndex" value="1">
                            <ul>
                                <li>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">客户</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input name="svrTitle" type="text" class="form-control col-md-6 col-xs-12" value="">
                                        </div>
                                    </div>
                                </li>
                                <li>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">概要</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input name="svrCustName" type="text" class="form-control col-md-6 col-xs-12" value="">
                                        </div>
                                    </div>
                                </li>
                                <li>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">服务类型</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <select name="svrType" id="svrType" class="form-control">
                                                <option value="">--请选择--</option>
                                                <option value="">12</option>
                                                <option value="建议">建议</option>
                                                <option value="咨询">咨询</option>
                                            </select>
                                        </div>
                                    </div>
                                </li>
                                <li>
                                    <button type="submit" class="btn btn-primary"> 查 &nbsp;&nbsp;&nbsp;&nbsp;询</button>
                                </li>
                            </ul>
                        </form>
                    </div>
                </div>
            </div>
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                    <div class="x_content">
                        <p class="text-muted font-13 m-b-30"></p>
                        <div id="datatable-responsive_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                            <div class="row">
                                <div class="col-sm-12">
                                    <table id="datatable-responsive" class="table table-striped table-bordered dt-responsive nowrap dataTable no-footer dtr-inline collapsed" cellspacing="0" width="100%" role="grid" aria-describedby="datatable-responsive_info" style="width: 100%;">
                                        <thead>
                                        <tr role="row">
                                            <th class="sorting_asc" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" aria-label="First name: activate to sort column descending" aria-sort="ascending">编号
                                            </th>
                                            <th class="sorting" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" aria-label="Last name: activate to sort column ascending">
                                                客户
                                            </th>
                                            <th class="sorting" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" aria-label="Last name: activate to sort column ascending">
                                                服务类型
                                            </th>
                                            <th class="sorting" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" aria-label="Last name: activate to sort column ascending">
                                                创建人
                                            </th>
                                            <th class="sorting" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" aria-label="Last name: activate to sort column ascending">
                                                创建日期
                                            </th>
                                            <th class="sorting" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" aria-label="Last name: activate to sort column ascending">
                                                概要
                                            </th>
                                            <th class="sorting" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" aria-label="Last name: activate to sort column ascending">
                                                分配给
                                            </th>
                                            <th class="sorting" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" aria-label="Last name: activate to sort column ascending">
                                                操作
                                            </th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr role="row" class="odd" th:each="dispatch:${dispatchPage.list}">
                                            <td tabindex="0" class="sorting_1" th:text="${dispatch.svrId}">1</td>
                                            <td tabindex="0" class="sorting_1" th:text="${dispatch.svrCustName}">客户</td>
                                            <td tabindex="0" class="sorting_1" th:text="${dispatch.svrType}">咨询</td>
                                            <td tabindex="0" class="sorting_1" th:text="${dispatch.svrDueTo}">11</td>
                                            <td tabindex="0" class="sorting_1" th:value="${#dates.format(dispatch.svrCreateDate,'yyyy-MM-dd')}">2007-12-08 00:00:00.0</td>
                                            <td tabindex="0" class="sorting_1" th:text="${dispatch.svrRequest}">概要</td>
                                            <td>
                                                <select name="svrDueTo" id="svrDueTo" class="form-control" >
                                                    <option value="0">--请选择--</option>
                                                    <option  th:text="${dispatch.svrDueTo}" selected value="1">--请选择--</option>
                                                    <option th:selected="${session.user.usr_id eq dispatch.svrDueId}" th:each="user:${session.userList}"
                                                            th:value="${user.usr_id}" th:text="${user.usr_name}" value="dd">wuhu
                                                    </option>
                                                </select>
                                                <a id="edit" href="#" th:onclick="|doEdit(this,${dispatch.svrId})|">分配</a>
                                            </td>
                                            <td>
                                                <a id="del" href="#" th:onclick="|doDel(this,${dispatch.svrId})|" >删除</a>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-5">
                                    <div class="dataTables_info" id="datatable-responsive_info"
                                         role="status" aria-live="polite">共<span th:text="${dispatchPage.total}">1</span>条记录
                                        <span th:text="${dispatchPage.current}">1</span>/<span
                                                th:text="${dispatchPage.pages}">5</span>页
                                    </div>
                                </div>
                                <span th:text="${page}">fdfd</span>
                                <div class="col-sm-7">
                                    <div class="dataTables_paginate paging_simple_numbers"
                                         id="datatable-responsive_paginate">
                                        <ul class="pagination">
                                            <li class="paginate_button previous" th:if="${dispatchPage.current}>1"><a
                                                    th:href="@{/service/dispatch(currPageNo=1)}"
                                                    aria-controls="datatable-responsive" data-dt-idx="0"
                                                    tabindex="0">首页</a>
                                            </li>
                                            <li class="paginate_button " th:if="${dispatchPage.current}>1"><a
                                                    th:href="@{/service/dispatch(currPageNo=${dispatchPage.current}-1)}"
                                                    aria-controls="datatable-responsive" data-dt-idx="1"
                                                    tabindex="0">上一页</a>
                                            </li>
                                            <li class="paginate_button " th:if="${dispatchPage.current}<${dispatchPage.pages}"><a
                                                    th:href="@{/service/dispatch(currPageNo=${dispatchPage.current}+1)}"
                                                    aria-controls="datatable-responsive" data-dt-idx="2"
                                                    tabindex="0">下一页</a>
                                            </li>
                                            <li class="paginate_button next" th:if="${dispatchPage.current}<${dispatchPage.pages}"><a
                                                    th:href="@{/service/dispatch(currPageNo=${dispatchPage.pages})}"
                                                    aria-controls="datatable-responsive" data-dt-idx="7"
                                                    tabindex="0">最后一页</a>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script layout:fragment="js">
    function doEdit(obj,id) {
        dueId = $(obj).prev().find(':selected').val();      //分配id
        dueName = $(obj).prev().find(':selected').text();     //分配人
        if (confirm("确认分配吗？")){
            $.ajax({
                url: "/service/upd",
                data:{"dueId":dueId,"dueName":dueName,"id":id},
                success:function (data) {
                    if (data=="true"){
                        alert("分配成功!");
                        return;
                    }else {
                        return;
                    }
                }
            })
        }

    }
    function doDel(obj, svr_Id) {
        if (confirm("你确定需要删除该用户信息吗？")) {
            $.ajax({
                type: "GET",
                url: "/service/del/" + svr_Id,
                success: function (data) {
                        alert("删除成功！");
                        $(obj).parents("tr").remove();
                },
                error: function (data) {
                    alert("删除成功！");
                    alert(obj.html())
                    $(obj).parents("tr").remove();
                }
            });
        }
    }
</script>
</html>